﻿// copyright (c) 2025 author:fio66<fio66@foxmail.com>. All rights reserved.
// date: 2025-10-27 15:26:32

#include "src/manager/audio_file_manager.h"

#include <filesystem>

#include "src/common/audio_helper.h"

namespace fio66 {
bool AudioFileManager::DetectAudioFile(std::string_view file_path) {
  std::filesystem::path path(file_path);
  if (!std::filesystem::exists(path) || !std::filesystem::is_directory(path)) {
    return false;
  }

  for (const auto &entry : std::filesystem::directory_iterator(path)) {
    if (entry.is_regular_file()) {
      std::string file = entry.path().string();
      auto audio_info = audio_helper::GetAudioFileInfo(file);
      if(audio_info){
        audio_file_info_list_.push_back(std::move(audio_info.value()));
      }
    }
  }

  return true;
}
}  // namespace fio66
